package cn.edu.scau.cmi.luotiansheng_chapter10;

import java.io.*;

public class Example10_11 {
	public static void main(String[] args) {
		File f=new File("apple.txt");
		try {
			FileOutputStream fos=new FileOutputStream(f);
			DataOutputStream outData=new DataOutputStream(fos);
			outData.writeInt(100);
			outData.writeLong(123466);
			outData.writeFloat(3.1415926f);
			outData.writeDouble(987654321.1234);
			outData.writeBoolean(true);
			outData.writeChars("How are you doing");
			
			
		}catch(IOException E) {
		}
		try {
			FileInputStream fis=new FileInputStream(f);
			DataInputStream inData=new DataInputStream(fis);
			System.out.println(inData.readInt());
			System.out.println(inData.readLong());
			System.out.println(inData.readFloat());
			System.out.println(inData.readDouble());
			System.out.println(inData.readBoolean());
			
			char c;
			while((c=inData.readChar())!='\0') {
				System.out.print(c);
			}
		}catch(IOException e) {
			
		}
		
	}
}
